package com.ask.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ask.dao.UserAccountMapper;
import com.ask.model.UserAccount;
import com.ask.service.UserAccountService;

@Service
@Transactional
public class UserAccountServiceImpl implements UserAccountService {
	
	@Autowired
	private UserAccountMapper userAccountMapper;
	
	public int deleteByPrimaryKey(Integer id) {
		
		return 0;
	}

	public int insert(UserAccount userAccount) {
		
		
		int a = userAccountMapper.insert(userAccount);
		
		return a;
	}

	public List<UserAccount> selectByParam(UserAccount userAccount) {
		List<UserAccount> list = userAccountMapper.selectByParam(userAccount);
		return list;
	}

	public UserAccount selectByPrimaryKey(Integer id) {
		UserAccount ua = userAccountMapper.selectByPrimaryKey(id);
		return ua ;
	}

	public int updateById(UserAccount userAccount) {
		int uu = userAccountMapper.updateById(userAccount);
		return uu;
	}

	public UserAccount selectByEmail(String email) {
//		UserAccount user = new UserAccount();
//		user.setEmail(email);
//		List<UserAccount> list = userAccountMapper.selectByParam(user);
//		if(list !=null && list.size()>0){
//		 UserAccount u =  list.get(0);
//		 return u;
//		}else{
//			return null;
//		}
		return userAccountMapper.selectByEmail(email);
		
	}

	@Override
	public UserAccount selectByMobile(String mobile) {
		UserAccount u = userAccountMapper.selectByMobile(mobile);
		return u;
	}

}
